package org.web.accesscontrollist.sdk.dto;

import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;

@Setter
@Getter
public class SaveUserResourceBindingBatchDTO implements Serializable {

    /**
     * 操作员信息，上次修改记录的操作人员工号，唯一标识操作人员。用于鉴权，校验是否有写权限，不允许为空。
     */
    @NotNull(message = "operatorDTO can't be null.")
    private OperatorDTO operatorDTO;

    /**
     * 绑定关系，AclUserResourceBindingDTO、角色、用户的绑定关系。
     */
    @NotNull(message = "AclUserResourceBindingDTO can't be null.")
    @Size(min = 1, max = 2000, message = "一次更新数据数量超过2000条上限。")
    private List<AclUserResourceBindingDTO> aclUserResourceBindingDTOList;

    public SaveUserResourceBindingBatchDTO(OperatorDTO operatorDTO, List<AclUserResourceBindingDTO> aclUserResourceBindingDTOList) {
        this.operatorDTO = operatorDTO;
        this.aclUserResourceBindingDTOList = aclUserResourceBindingDTOList;
        // 构建对象的同时校验参数的合法性。
        AclResourceHelper.checkSaveUserResourceBindingBatchDTO(this);
    }
}
